<template>
  <day-sheet2 excel-config-id="1005272615327846400"></day-sheet2>
</template>

<script>
import LuckyExcel from 'luckyexcel';
import {Message} from "element-ui";
import moment from "moment";
import daySheet2 from "./daySheet2";

export default {
  name: "daySheet",
  components: {daySheet2},
  created() {

  },
  methods: {
    init() {
      this.axios.post('/jmreport/exportAllExcelStream', {
        "excelConfigId": "1005272615327846400",
        "queryParam": {
          "pageNo": "1",
          "pageSize": 10,
          "currentPageNo": "1",
          "currentPageSize": 10,
          "ynday": moment().format('yyyy-MM-DD')
        }
      }, {responseType: 'arraybuffer'}).then(res => {

        let blob = new Blob([res.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});

        let file = new File([blob], "example.xlsx", {
          type: blob.type,
        });

        this.file = file;

        LuckyExcel.transformExcelToLucky(file, function (exportJson, luckysheetfile) {
            if (exportJson.sheets == null || exportJson.sheets.length === 0) {
              Message.warning("读取excel文件内容失败");
              return;
            }
            exportJson.sheets[0]["zoomRatio"] = 0.8;
            const options = {
              container: 'luckysheet2',
              showinfobar: false,
              data: exportJson.sheets,
              showsheetbar: false,
              sheetFormulaBar: false,
            };
            luckysheet.create(options);
          }, function (err) {
            Message.warning('Import failed. Is your fail a valid xlsx?');
          }
        );

      })
    },

  },
  data() {
    return {
      xs: null,
      fileList: [],
      file: null,
      autoGenerateColumns: false,
      spread: null,
      selectedFile: null,
    };
  },
  mounted() {
  },
}
</script>

<style scoped>
#luckysheet2 {
  margin: 0px;
  padding: 0px;
  position: relative;
  width: 100%;
  height: 100%;
  left: 0px;
  top: 0px;
}
</style>
